package com.cl.util;

import java.util.ResourceBundle;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import com.alibaba.fastjson.JSONObject;

public class EnumTag extends TagSupport{

	private static final long serialVersionUID = 4512241072079966773L;
	private String type;
	private String value;
	
	@Override
	public int doEndTag() throws JspException {
		try {
			String json = ResourceBundle.getBundle("enumConfig").getString(type);
			JSONObject enumJson = JSONObject.parseObject(json);
			JspWriter writer = pageContext.getOut();
			writer.print(enumJson.getString(value));
		} catch (Exception e) {
			e.printStackTrace();
		}
		return EVAL_PAGE;
	}
	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
}
